package com.rc.pojo.po;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.keygen.KeyGenerators;
import com.rc.common.constant.RoleEnum;
import com.rc.common.model.BaseUserEntity;
import com.rc.common.util.UserRoleTypeHandler;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 员工信息 实体类。
 *
 * @author 27806
 * @since 2024-06-15
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "user", schema = "rc")
public class User implements BaseUserEntity, Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @Id(keyType = KeyType.Generator,value = KeyGenerators.snowFlakeId)
    private Long id;

    /**
     * 角色id 0管理员 1农场管理员 2雇工
     */
    @Column(typeHandler = UserRoleTypeHandler.class)
    private RoleEnum role;

    /**
     * 姓名
     */
    private String name;

    private String avatar;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 性别
     */
    private Integer sex;

    /**
     * 身份证号
     */
    private String idNumber;

    /**
     * 状态 0:禁用，1:启用
     */
    private Integer status;

    /**
     * 创建时间
     */
    @Column(onInsertValue = "now()")

    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(onInsertValue = "now()",onUpdateValue = "now()")
    private LocalDateTime updateTime;


    /**
     * 农场id
     */
    @Column(tenantId = true)
    private Long farmId;

    private Long createUser;

    private Long updateUser;
}
